package com.pengshun.modules.api.user.controller;

import com.pengshun.modules.api.coal.validator.First;
import com.pengshun.modules.api.coal.validator.Second;
import com.pengshun.modules.api.user.para.CarPara;
import com.pengshun.modules.api.user.service.UserCarBossService;
import com.pengshun.modules.common.BaseResult;
import com.pengshun.modules.domain.User;
import com.pengshun.modules.security.Authorization;
import com.pengshun.modules.security.CurrUserInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

@RestController
@RequiredArgsConstructor
@Api(tags = "车老板管理")
@RequestMapping("/api/boss")
@ApiIgnore
public class UserCarBossController {

    private  final UserCarBossService userCarBossService;

    @ApiOperation(value = "车老板列表",notes = " ")
    @GetMapping(value = "/list")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jwtToken", value = "jwtToken", dataType = "string", required = true, paramType = "header"),
            @ApiImplicitParam(name = "status", value = "类型(0:待关联，1已关联，2拒绝,3解绑)", dataType = "int", required = true, paramType = "query"),
            @ApiImplicitParam(name = "page", value = "当前页", dataType = "int", required = true, paramType = "query"),
            @ApiImplicitParam(name = "size", value = "请求条数", dataType = "int", required = true, paramType = "query"),
    })
    @Authorization
    public BaseResult list(@ApiIgnore @CurrUserInfo User user, @ApiIgnore @Validated(value = {First.class}) CarPara para) throws Exception {
        para.setUserId(user.getId());
        BaseResult res = userCarBossService.list(para);
        return res;
    }

    @ApiOperation(value = "接单车辆列表",notes = "")
    @GetMapping(value = "/car-list")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "jwtToken", value = "jwtToken", dataType = "string", required = true, paramType = "header"),

    })
    @Authorization
    public BaseResult carList(@ApiIgnore @CurrUserInfo User user) throws Exception {
        BaseResult res = userCarBossService.carList(user.getId());
        return res;
    }

}
